#include <stdlib.h>
#include <Judy.h>
#include <stdio.h>

#include "globals.h"
#include "limits.h"
#include "datatypes.h"

Concept* get_atomic_concept(unsigned char* name) {
	PWord_t pvalue;
	JSLG(pvalue, atomic_concepts, name);
	if (pvalue == NULL)
		return NULL;
	return (Concept*) *pvalue;
}

void put_atomic_concept(unsigned char* name, Concept* c) {
        PWord_t pvalue;

        JSLI(pvalue, atomic_concepts, name);
        if (pvalue == PJERR) {
                fprintf(stderr, "could not insert atomic concept %s, aborting", name);
                exit(-1);
        }
        *pvalue = (Word_t) c;
}


Role* get_atomic_role(unsigned char* name) {
	PWord_t pvalue;
	JSLG(pvalue, atomic_roles, name);
	if (pvalue == NULL)
		return NULL;
	return (Role*) *pvalue;
}

void put_atomic_role(unsigned char* name, Role* r) {
        PWord_t pvalue;

        JSLI(pvalue, atomic_roles, name);
        if (pvalue == PJERR) {
                fprintf(stderr, "could not insert atomic role %s, aborting", name);
                exit(-1);
        }
        *pvalue = (Word_t) r;
}

